package net.onceface.core.domain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import net.onceface.core.domain.enums.MemberLevel;
import net.onceface.infra.domain.AbstractEntity;

/**
 * 客户的重要信息（多为不允许修改参数）
 * **/
@Entity
@Table(name = "SYS_CLIENT_PROTECT_INFO",
	uniqueConstraints = {@UniqueConstraint(columnNames={"CLIENT_ID"})})
@NamedQueries({
	@NamedQuery(name = "Client.findProtectByClientId", query = "SELECT _protectInfo FROM ClientProtectInfo _protectInfo WHERE _protectInfo.clientId = :clientId")
})
public class ClientProtectInfo extends AbstractEntity{

	/**
	 * 
	 */
	private static final long serialVersionUID = 2631783964718798985L;

	/**
	 * 会员等级，非会员为Z；
	 * **/
	@Column(name = "LEVEL")
	private MemberLevel level;
	
	/**
	 * 总余额
	 * **/
	@Column(name = "BALANCE")
	private double balance;
	
	/**
	 * 可用余额
	 * **/
	@Column(name = "AVAILABLE_BALANCE")
	private double availableBalance;
	
	/**
	 * 升级经验
	 * **/
	@Column(name = "TOTAL_EXP")
	private int totalExp;
	
	/**
	 * 已有经验
	 * **/
	@Column(name = "HAVE_EXP")
	private int haveExp;
	
	/**
	 * 返点
	 * **/
	@Column(name = "POINT")
	private int point;
	
	/**
	 * 客户ID
	 * **/
	@Column(name = "CLIENT_ID")
	private Long clientId;
	
	/**
	 * 根据客户ID查找客户的重要信息
	 * **/
	public static ClientProtectInfo findByClientId(Long clientId){
		return getRepository()
				.createNamedQuery("Client.findProtectByClientId")
				.addParameter("clientId", clientId)
				.singleResult();
	}
	
	@Override
	public String[] businessKeys() {
		// TODO Auto-generated method stub
		return null;
	}

	public MemberLevel getLevel() {
		return level;
	}

	public void setLevel(MemberLevel level) {
		this.level = level;
	}

	public double getBalance() {
		return balance;
	}

	public void setBalance(double balance) {
		this.balance = balance;
	}

	public double getAvailableBalance() {
		return availableBalance;
	}

	public void setAvailableBalance(double availableBalance) {
		this.availableBalance = availableBalance;
	}

	public int getTotalExp() {
		return totalExp;
	}

	public void setTotalExp(int totalExp) {
		this.totalExp = totalExp;
	}

	public int getHaveExp() {
		return haveExp;
	}

	public void setHaveExp(int haveExp) {
		this.haveExp = haveExp;
	}

	public int getPoint() {
		return point;
	}

	public void setPoint(int point) {
		this.point = point;
	}

	public Long getClientId() {
		return clientId;
	}

	public void setClientId(Long clientId) {
		this.clientId = clientId;
	}

	
}
